package excel

func (x *xlsx) SetCellValue(cell string, value any) {
	cell = rc2cell(cell)
	active_name := x.active_name
	x.f.SetCellValue(active_name, cell, value)
}

func (x *xlsx) GetCellValue(cell string) (string, error) {
	cell = rc2cell(cell)
	active_name := x.active_name
	return x.f.GetCellValue(active_name, cell)
}

func (x *xlsx) SetCellStyle(hcell, vcell string, styleID int) {
	hcell = rc2cell(hcell)
	vcell = rc2cell(vcell)
	active_name := x.active_name
	x.f.SetCellStyle(active_name, hcell, vcell, styleID)
}

func (x *xlsx) GetCellStyle(cell string) (int, error) {
	cell = rc2cell(cell)
	active_name := x.active_name
	return x.f.GetCellStyle(active_name, cell)
}

func (x *xlsx) SetCellHyperLink(cell, link, linkType string) {
	cell = rc2cell(cell)
	active_name := x.active_name
	x.f.SetCellHyperLink(active_name, cell, link, linkType)
}

func (x *xlsx) GetCellHyperLink(cell string) (string, bool, error) {
	cell = rc2cell(cell)
	active_name := x.active_name
	ok, link, e := x.f.GetCellHyperLink(active_name, cell)
	return link, ok, e
}

func (x *xlsx) SetCellFormula(cell, formula string) {
	cell = rc2cell(cell)
	active_name := x.active_name
	x.f.SetCellFormula(active_name, cell, formula)
}

func (x *xlsx) GetCellFormula(cell string) (string, error) {
	cell = rc2cell(cell)
	active_name := x.active_name
	return x.f.GetCellFormula(active_name, cell)
}

// 合并单元格
func (x *xlsx) MergeCell(hcell, vcell string) {
	hcell = rc2cell(hcell)
	vcell = rc2cell(vcell)
	active_name := x.active_name
	x.f.MergeCell(active_name, hcell, vcell)

}

func (x *xlsx) GetMergeCells() ([][]string, error) {
	active_name := x.active_name
	MergeCells, e := x.f.GetMergeCells(active_name)
	if e != nil {
		return nil, e
	}

	ret := [][]string{}
	for _, v := range MergeCells {
		ret = append(ret, v)
	}

	return ret, nil
}
